import {
  mapGetters
} from 'vuex'
export default {
  computed: {
    ...mapGetters('m_cart', ['total'])
  },
  watch:{
    total:{
      handler(){
        this.setBadge()
      },
      immediate:true
    }
  },
  onShow() {
    this.setBadge()
  },
  methods: {
    setBadge() {
      uni.setTabBarBadge({
        //这里面的四个tabbar索引从0开始
        index: 2,
        //text必须是字符串
        text: this.total + ''
      })
    }
  },
}
